package compro.admission.form.evaluation;
import compro.admission.form.entity.Application;
import compro.admission.form.entity.Education;
import compro.admission.form.entity.ProfessionalExperience;

public class Evaluation {
	
	private Application application;
	public static enum resultType {PASS , CONTINUE,UNDERTERMINED , FAIL }; 

	public Evaluation(){
		
	}
	public Evaluation(Application application){
		this.application = application;
	}
	public resultType Evaluate(){
		resultType result = checkEducation();
		if(result != resultType.CONTINUE)
			return result;
		else
			 return checkWorkExperience();
			
	}
	public resultType checkEducation(){
		Education education = application.getEducation();
		if(checkDegreeField(education)== resultType.FAIL)
			return resultType.FAIL;
		else
			return checkGPA(education);
	}
	public resultType checkDegreeField(Education education){
		if( !education.getDegreeType().equals("BS"))
			return resultType.FAIL;
		
		switch(education.getDegreeField()){
			case "CS" : return resultType.PASS;
			case "EE" : return resultType.PASS;
			case "CE" : return resultType.PASS;
			case "IT" : return resultType.PASS;
			default: return resultType.FAIL; 
		}
	} 
	public resultType checkGPA(Education education){
		if(education.getGradingScale().equalsIgnoreCase("0-4")){
			if(education.getGpa() >= 3.5)
				return resultType.PASS;
			else if(education.getGpa() >= 3.0 )
				return resultType.CONTINUE;
			else
				return resultType.FAIL;
		}else
			return resultType.UNDERTERMINED;
			
	}
	public resultType checkWorkExperience(){
		ProfessionalExperience professional = application.getProfessionalExperience();
		int year = Integer.parseInt(professional.getExperienceYears());
		if(year >= 2)
			return resultType.PASS;
		else if(year >= 1)
			return resultType.UNDERTERMINED;
		else
			return resultType.FAIL;
	}

	public Application getApplication() {
		return application;
	}

	public void setApplication(Application application) {
		this.application = application;
	}

}
